package org.fhm.zdte.client.service;

import org.fhm.substrate.annotation.Component;
import org.fhm.substrate.service.LoggerHandler;
import org.fhm.substrate.standard.ILogger;
import org.fhm.zdte.common.service.channel.AbstractUDPChannelManager;

import java.util.Objects;

/**
 * Backup client UDP channel manager.
 *
 * @author 谭波
 * @since 2024/4/7
 */
@Component("BACKUP")
public class BackupClientUDPChannelManager extends AbstractUDPChannelManager {

    private final ILogger logger = LoggerHandler.getLogger(ClientUDPChannelManager.class);

    @Override
    public void initializeChannelManager() {
        if (Objects.isNull(dc)) {
            synchronized (this) {
                if (Objects.isNull(dc)) {
                    openChannel(0).enableChannel();
                    logger.info("enable backup udp successful");
                    setSleepTime();
                }
            }
        }
    }
}
